#ifndef unigame_Plane_h
#define unigame_Plane_h

#include "Vector3.h"

namespace unigame
{
	class Plane
	{
	public:
		Plane():m_normal(0, 1, 0), m_distance(0){};
		~Plane(){};

		Plane(const Vector3f& p1, const Vector3f& p2, const Vector3f p3)
		{
			m_normal = (p2 - p1).cross(p3 - p1);
			m_normal.normalize();
			m_distance = -m_normal.dot(p1);
		}

		Vector3f& normal()
		{
			return m_normal;
		}

		float distance()
		{
			return m_distance;
		}

		void distance(float value)
		{
			m_distance = value;
		}

		float distanceTo(const Vector3f& point)
		{
			return m_distance + m_normal.dot(point);
		}

	private:
		Vector3f m_normal;
		float m_distance;
	};
}

#endif